<template>
	<view>
		<Navbar></Navbar>
		<view class="u-m-t-20">
			<view class="u-flex u-row-between u-line-bottom u-p-30 u-back-white" v-for="item in list" :key="item.id"
				@click="goAssist(item.id)">
				<view class="u-flex">
					<u-icon :name="item.icon" custom-prefix="custom-icon" size="38"></u-icon>
					<view class="u-font-28 u-font-bold u-m-l-20">{{item.name}}</view>
				</view>
				<view>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
		</view>
		<Bottom :isReturn="true"></Bottom>
	</view>
</template>

<script>
	import Navbar from '@/components/Navbar.vue'
	import Bottom from '@/components/Bottom.vue'
	import { dowmCompanyFile } from '@/network/api.js'
	import share from '@/mixins/share.js'
	export default {
		mixins: [share],
		components: {
			Navbar,
			Bottom
		},
		data() {
			return {
				list: [{
					    id: 15,
						name: '平台介绍',
						icon: 'icon-warp'
				    },
					{
						id: 1,
						name: '用户协议',
						icon: 'icon-lsit',
					},{
						id: 2,
						name: '隐私协议',
						icon: 'icon-list1',
					},
					/* {
						id: 5,
						name: '公司入驻协议',
						icon: 'icon-store',
					}, */
					{
						id: 6,
						name: '积分说明',
						icon: 'icon-vip',
					},
					{
						id: 16,
						name: '能量值说明',
						icon: 'icon-top',
					}/* ,
					{
						id: 17,
						name: '青创私董公约',
						icon: 'icon-warp',
					},
					{
						id: 18,
						name: '场地公约',
						icon: 'icon-card',
					},
					{
						id: 99,
						name: '意见反馈',
						icon: 'icon-conmentpinglun',
					} */
				]
			}
		},
		onLoad(){
			this.mixinsShare.page = `/pages/helpCenter/helpCenter?inviterId=${uni.getStorageSync("user_id")}`
			this.mixinsShare.image = 'https://medv-new.oss-cn-shanghai.aliyuncs.com/images/common/20240624979559784584.png'
		},
		methods: {
			goAssist(id) {
				switch (id) {
					case 99:
						this.handleGoFeedback()
						break;
					default:
					    uni.navigateTo({
					    	url: '/operate/agreement/agreement?type=' + id
					    })
						break;
				}
			},
			handleDownLoad() {
				dowmCompanyFile().then(fileRes => {
					uni.downloadFile({
						url: fileRes.data.url,
						success: (data) => {
							if (data.statusCode === 200) {
								uni.saveFile({
									tempFilePath: data.tempFilePath,
									filePath: `${wx.env.USER_DATA_PATH}/企业认证入驻协议.pdf`,
									success: function(res) {
										uni.showToast({
											icon: 'none',
											mask: true,
											title: '文件已保存：' + res.savedFilePath,
											duration: 2000,
										});
										setTimeout(() => {
											uni.openDocument({
												showMenu: true,
												filePath: res
													.savedFilePath,
												success: function(res) {}
											});
										}, 2000)
									}
								});
							}
						},
						fail: (err) => {
							uni.showToast({
								icon: 'none',
								mask: true,
								title: '失败请重新下载',
							});
						},
					});
				})
			},
			handleGoFeedback() {
				uni.navigateTo({
					url: "/operate/feedback/feedback?type=2"
				})
			}
		}
	}
</script>